package com.imooc.imoocbilibili.vo;

import cn.hutool.core.util.EnumUtil;
import com.imooc.imoocbilibili.enums.OmsEnums;
import lombok.Data;

import java.util.Date;

/**
 * @author 江黎
 * @since 2022-04-12
 */
@Data
public class VersionConfigVO {
    /**
     * 主键id
     */
    private Integer versionId;
    /**
     * 端 1:android 2:ios 3:web
     */
    private Integer type;
    /**
     * 版本号
     */
    private String versionNumber;
    /**
     * 更新类型 1:非强制更新 2:强制更新
     */
    private Integer updateType;
    /**
     * 发布方式 1:立即发布 2:定时发布
     */
    private Integer pushType;
    /**
     * 发布时间
     */
    private Date pushTime;
    /**
     * 版本描述
     */
    private String description;
    /**
     * 状态 1:已发布 2:定时发布 3:已撤回
     */
    private Integer status;
    /**
     * 包下载地址
     */
    private String url;
    /**
     * 是否撤回 0:否 1:是
     */
    private Integer isCancel;

    private String typeName;
    private String updateTypeName;
    private String pushTypeName;
    private String statusName;
    private String isCancelName;

    public void setTypeName() {
        OmsEnums.VersionTypeEnum versionTypeEnum = EnumUtil.likeValueOf(OmsEnums.VersionTypeEnum.class, this.type);
        this.typeName = versionTypeEnum.getMessage();
    }

    public void setUpdateTypeName() {
        OmsEnums.UpdateTypeEnum updateTypeEnum = EnumUtil.likeValueOf(OmsEnums.UpdateTypeEnum.class, this.type);
        this.updateTypeName = updateTypeEnum.getMessage();
    }

    public void setPushTypeName() {
        OmsEnums.PushTypeEnum pushTypeEnum = EnumUtil.likeValueOf(OmsEnums.PushTypeEnum.class, this.type);
        this.pushTypeName = pushTypeEnum.getMessage();
    }

    public void setStatusName() {
        OmsEnums.PushStatusEnum pushStatusEnum = EnumUtil.likeValueOf(OmsEnums.PushStatusEnum.class, this.type);
        this.statusName = pushStatusEnum.getMessage();
    }

    public void setIsCancelName() {
        this.isCancelName = this.isCancel == 0 ? "" : "已撤回";
    }
}
